🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / service / src / androidMain / kotlin / org / meshtastic / core / service / worker / MeshLogCleanupWorker.kt
Displaying Raw • Download
core/service/src/androidMain/kotlin/org/meshtastic/core/service/worker/MeshLogCleanupWorker.kt e85300531e124df08788c1b765d50af1bf6d516d (e8530053) Text, 2.40 KB
T8b949e/*
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.service.worker
Tff7b72import T7ee787android.content.Context
Tff7b72import T7ee787androidx.work.CoroutineWorker
Tff7b72import T7ee787androidx.work.WorkerParameters
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787org.koin.android.annotation.KoinWorker
Tff7b72import T7ee787org.meshtastic.core.repository.MeshLogPrefs
Tff7b72import T7ee787org.meshtastic.core.repository.MeshLogRepository
Tf0883e@KoinWorker
Tff7b72class T56d364MeshLogCleanupWorkerTb4b4b4(
Te6edf3appContextTb4b4b4: Te6edf3ContextTb4b4b4,
Te6edf3workerParamsTb4b4b4: Te6edf3WorkerParametersTb4b4b4,
Tff7b72private Tff7b72val Te6edf3meshLogRepositoryTb4b4b4: Te6edf3MeshLogRepositoryTb4b4b4,
Tff7b72private Tff7b72val Te6edf3meshLogPrefsTb4b4b4: Te6edf3MeshLogPrefsTb4b4b4,
Tb4b4b4) Tb4b4b4: Te6edf3CoroutineWorkerTb4b4b4(Te6edf3appContextTb4b4b4, Te6edf3workerParamsTb4b4b4) Tb4b4b4{
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffTooGenericExceptionCaughtTa5d6ff"Tb4b4b4)
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffdoWorkTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3Result Tff7b72= Tff7b72try Tb4b4b4{
Tff7b72val Te6edf3retentionDays Tff7b72= Te6edf3meshLogPrefsTb4b4b4.Te6edf3retentionDaysTb4b4b4.Te6edf3value
Tff7b72if Tb4b4b4(Tff7b72!Te6edf3meshLogPrefsTb4b4b4.Te6edf3loggingEnabledTb4b4b4.Te6edf3valueTb4b4b4) Tb4b4b4{
Te6edf3loggerTb4b4b4.Te6edf3i Tb4b4b4{ Ta5d6ff"Ta5d6ffSkipping cleanup because mesh log storage is disabledTa5d6ff" Tb4b4b4}
Tb4b4b4} Tff7b72else Tff7b72if Tb4b4b4(Te6edf3retentionDays Tff7b72=Tff7b72= T79c0ff0Tb4b4b4) Tb4b4b4{
Te6edf3loggerTb4b4b4.Te6edf3i Tb4b4b4{ Ta5d6ff"Ta5d6ffSkipping cleanup because retention is set to never deleteTa5d6ff" Tb4b4b4}
Tb4b4b4} Tff7b72else Tb4b4b4{
Tff7b72val Te6edf3retentionLabel Tff7b72=
Tff7b72if Tb4b4b4(Te6edf3retentionDays Tff7b72=Tff7b72= Tff7b72-T79c0ff1Tb4b4b4) Tb4b4b4{
Ta5d6ff"Ta5d6ff1 hourTa5d6ff"
Tb4b4b4} Tff7b72else Tb4b4b4{
Ta5d6ff"Tffd700$Te6edf3retentionDaysTa5d6ff daysTa5d6ff"
Tb4b4b4}
Te6edf3loggerTb4b4b4.Te6edf3d Tb4b4b4{ Ta5d6ff"Ta5d6ffCleaning logs older than Tffd700$Te6edf3retentionLabelTa5d6ff" Tb4b4b4}
Te6edf3meshLogRepositoryTb4b4b4.Te6edf3deleteLogsOlderThanTb4b4b4(Te6edf3retentionDaysTb4b4b4)
Te6edf3loggerTb4b4b4.Te6edf3i Tb4b4b4{ Ta5d6ff"Ta5d6ffSuccessfully cleaned old MeshLog entriesTa5d6ff" Tb4b4b4}
Tb4b4b4}
Te6edf3ResultTb4b4b4.Te6edf3successTb4b4b4(Tb4b4b4)
Tb4b4b4} Tff7b72catch Tb4b4b4(Te6edf3eTb4b4b4: Te6edf3ExceptionTb4b4b4) Tb4b4b4{
Te6edf3loggerTb4b4b4.Te6edf3eTb4b4b4(Te6edf3eTb4b4b4) Tb4b4b4{ Ta5d6ff"Ta5d6ffFailed to clean MeshLog entriesTa5d6ff" Tb4b4b4}
Te6edf3ResultTb4b4b4.Te6edf3failureTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tff7b72companion Tff7b72object Tb4b4b4{
Tff7b72const Tff7b72val Te6edf3WORK_NAME Tff7b72= Ta5d6ff"Ta5d6ffmeshlog_cleanup_workerTa5d6ff"
Tb4b4b4}
Tff7b72private Tff7b72val Te6edf3logger Tff7b72= Te6edf3LoggerTb4b4b4.Te6edf3withTagTb4b4b4(Te6edf3WORK_NAMETb4b4b4)
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.06s